Imports Janus.Windows.GridEX
Imports System.IO

Public Class frmPOSTable
    Dim dvTables As DataView
    Private Sub frmTableDetail_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Me.lblCaption.Text = "TABLES"
            Dim r As Rectangle
            r = Me.GridFloor.GetCardBounds(GridFloor.Row)
            r.Height = 300

            Me.GridFloor.ExpandableCards = False

            Dim LoadTableStrQuery As String = ""
            LoadTableStrQuery = LoadTableStrQuery + " select T0.TableCode,T0.TableName,T0.FloorCode,isnull(T1.DocEntry,0) DocEntry,"
            LoadTableStrQuery = LoadTableStrQuery + " cast (isnull(T1.DocEntry,0) as nvarchar(10)) + SPACE(35-LEN(cast (isnull(T1.DocEntry,0) as nvarchar(10)))-LEN(CAST (isnull(T1.DocTotal,0) as nvarchar(100)))) + CAST (isnull(T1.DocTotal,0) as nvarchar(100)) EntryAmount "
            LoadTableStrQuery = LoadTableStrQuery + " from _Table T0 with(nolock)"
            LoadTableStrQuery = LoadTableStrQuery + " left join ORDR T1 with(nolock) on T0.TableCode=T1.U_TableCode and T1.DocStatus='O'"
            LoadTableStrQuery = LoadTableStrQuery + " where T0.IsActive='True'"
            dvTables = Functions.SAP_Local_RunQuery(LoadTableStrQuery).DefaultView


            GridFloor.DataSource = Functions.SAP_Local_RunQuery("select FloorCode,FloorName from _Floor where IsActive='True'")

        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Private Sub GridFloor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GridFloor.Click
        Dim FloorCode As String = GridFloor.GetValue("FloorCode")
        If FloorCode Is DBNull.Value Then
            Return
        End If

        Me.GridTable.Enabled = True
        FilterTable("FloorCode='" + FloorCode + "'")
    End Sub

    Private Sub FilterTable(ByVal connFilter As String)
        Try
            dvTables.RowFilter = Nothing
            dvTables.RowFilter = connFilter
            GridTable.DataSource = dvTables
            If GridTable.RowCount > 0 Then GridTable.Row = 0
        Catch ex As Exception
        End Try
    End Sub
  

    Private Sub btnTakeAway_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTakeAway.Click
        Dim frm As New frmPOSTouch
        frm.ShowDialog()
    End Sub

    Private Sub GridTable_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GridTable.Click
        Dim frm As New frmPOSTouch
        frm.TableCode = GridTable.GetValue("TableCode").ToString
        frm.DocEntry = GridTable.GetValue("DocEntry").ToString
        If frm.ShowDialog() = Windows.Forms.DialogResult.OK Then

        End If
    End Sub
End Class